package cn.xz.zgsg.activity


import android.os.Handler
import android.util.Log
import android.view.View
import android.widget.SeekBar
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import cn.xz.zgsg.R
import cn.xz.zgsg.adapter.*
import cn.xz.zgsg.base.BaseActivity
import cn.xz.zgsg.base.BaseApplication
import cn.xz.zgsg.bean.*
import cn.xz.zgsg.databinding.ActivityMain1Binding
import cn.xz.zgsg.dialog.AddU3DWelComeDialog
import cn.xz.zgsg.net.ControlDevice
import cn.xz.zgsg.net.OkHttpUtil
import cn.xz.zgsg.util.*
import com.alibaba.fastjson.JSONArray
import okhttp3.*
import java.io.IOException
import java.util.*

/**
 * 一楼界面*/
class Main1Activity : BaseActivity<ActivityMain1Binding>(R.layout.activity_main1) {

    //标识符
    private var mTag = 0

    //设备信息
    private var mDevice: DeviceList? = null

    //当前视频进度值
    private var pMove = 0
    private var handler: Handler? = null

    //序厅欢迎词列表适配器
    private var hycZhAdapter: U3dHycAdapter? = null
    //建设背景欢迎词
    private var jsAdapter: U3dHycAdapter? = null
    //序厅视频播放
    private var mXTAdapter: CJListAdapter? = null
    //大事记列表
    private var mAdapter1321: CJListAdapter? = null
    //新大事记
    private var mAdapter132: GetListUtils.QnZtListAdapter? = null
    private var mAdapter1322: GetListUtils.QnZtListAdapter? = null
    //创建基础列表
    private var mAdapterCJJC1: CJListAdapter111? = null
    //阶段成果一级列表
    private var mAdapter199: CJListAdapter? = null


    companion object{
        //当前选择的创建基础下标
        var mSInt = 0
    }

    override fun initData() {
        //获取跳转数据
        mTag = intent.getIntExtra(CommonLib.JUMP_TYPE, -1)
        //获取当前设备信息
        if (mTag != -1) {
            mDevice = ControlDevice.getThisDevice(mTag)
            //mDevice!!.ip = "192.168.10.23"
        }
        //如果数据异常直接退出
        if (mTag == -1 || mDevice == null) {
            ToastUtil.show("当前数据异常")
            finish()
        }
        //开启定时器获取视频进度
        handler = Handler()
        handler?.post(movieR)
        //获取当前音量
        getVoice()
        showView()
        //如果是多级列表
        //设置层级
        setList()
        //设置序厅视频列表
        initXTRV()
        //设置欢迎词适配器
        initRV()
        //设置建设背景适配器
        initJSRV()
        //设置合规沙盘列表数据
        onHGRV()

        //获取本地资源列表
        //获取本地列表
        getLocalList()
    }

    override fun initEvent() {
        //返回
        mDataBind.tvBack.setOnClickListener {
            finish()
        }


        /**序厅*/
        //序厅: 视频播放
        mDataBind.tvSp.setOnClickListener {
            val url = "http://" + mDevice!!.ip + ":8030/?act=unity&states=Video&object="
            OkHttpUtil.post(url);
            mDataBind.llcXtSpbf.visible()
            mDataBind.clXtHyc.gone()
        }
        //播放
        mDataBind.zkPlay.setOnClickListener {
            //setPlay(1)
            U3dHttp.PlayMovie(mDevice!!.ip)
        }
        //暂停
        mDataBind.zkPause.setOnClickListener {
            //setPlay(2)
            U3dHttp.PauseMovie(mDevice!!.ip)
        }
        //重播
        mDataBind.zkReplay.setOnClickListener {
            //setPlay(3)
            U3dHttp.ReplayMovie(mDevice!!.ip)
        }
        //上一页
        mDataBind.zkPageUp.setOnClickListener {
            //setPlay(9)
            U3dHttp.PrevPage(mDevice!!.ip)
        }
        //下一页
        mDataBind.zkPageDown.setOnClickListener {
            //setPlay(10)
            U3dHttp.NextPage(mDevice!!.ip)
        }
        //声音滑动监听
        mDataBind.zkVolumeSeekbar.setOnSeekBarChangeListener(object :
            SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                LocalHttp.changeVoice(mDevice!!.ip, progress)
            }

            override fun onStartTrackingTouch(seekBar: SeekBar) {
            }

            override fun onStopTrackingTouch(seekBar: SeekBar) {
            }
        })
        //视频滑动监听
        mDataBind.zkVideoSeekbar.setOnSeekBarChangeListener(object :
            SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                pMove = progress
            }

            override fun onStartTrackingTouch(seekBar: SeekBar) {
            }

            override fun onStopTrackingTouch(seekBar: SeekBar) {
                //LocalHttp.changeMovie(mDevice!!.ip, pMove)
                U3dHttp.changeMovie(mDevice!!.ip, pMove)
            }
        })
        //序厅: 欢迎词
        mDataBind.tvHyc.setOnClickListener {
            val url = "http://" + mDevice!!.ip + ":8030/?act=unity&states=Word&object="
            OkHttpUtil.post(url);
            mDataBind.llcXtSpbf.gone()
            mDataBind.clXtHyc.visible()
            //获取程序的欢迎词数据
            initGet3DHYC()
        }
        //添加欢迎词
        mDataBind.tvTjhyc.setOnClickListener {
            AddU3DWelComeDialog.newInstance(
                true,
                120,
                "请输入文字",
                "",
                mDevice!!,
                object : AddU3DWelComeDialog.OnClickListener {
                    override fun onYes(i: Int, s: String, f: String) {
                        //删除按钮
                        val url =
                            "http://" + mDevice!!.ip + ":8030/?act=AddText&contain=" + s + "&size=" + i + "&font=" + f
                        OkHttpUtil.get(url, object : Callback {
                            override fun onFailure(call: Call, e: IOException) {}

                            @Throws(IOException::class)
                            override fun onResponse(call: Call, response: Response) {
                                if (response.isSuccessful) {
                                    mDataBind.tvTjhyc.postDelayed({
                                        initGet3DHYC()
                                    }, 500)
                                }
                            }
                        })
                    }
                }
            ).show(this@Main1Activity.supportFragmentManager, "AddU3DWelComeDialog1312143")
        }
        //欢迎词列表循环
        mDataBind.tvXtlbxh.setOnClickListener {
            U3dHttp.LoopWel(mDevice!!.ip)
        }
        //欢迎词停止滚动
        mDataBind.tvTczg.setOnClickListener {
            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=StopLoop&object="
            OkHttpUtil.post(url);
        }
        //欢迎词鼠键
        mDataBind.tvShjj.setOnClickListener {
            ARouter.to(SJActivity::class.java,mDevice!!.ip)
        }
        //屏幕开
        mDataBind.tvPmk.setOnClickListener {
            ControlDevice.openThisDevice(2343)
            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=OpenDoor&object="
            OkHttpUtil.post(url)

            //关声音
            LocalHttp.changeVoice(mDevice!!.ip, 0)


            //开三个灯
            mDataBind.tvPmk.postDelayed({
               ControlDevice.openThisLight(7757)
            },200)
            mDataBind.tvPmk.postDelayed({
                ControlDevice.openThisLight(7758)
            },400)
            mDataBind.tvPmk.postDelayed({
                ControlDevice.openThisLight(7759)
            },600)
        }
        //屏幕合
        mDataBind.tvPmh.setOnClickListener {
            ControlDevice.closeThisDevice(2344)
            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=CloseDoor&object="
            OkHttpUtil.post(url)

            //开声音
            LocalHttp.changeVoice(mDevice!!.ip, 80)


            //关三个灯
            mDataBind.tvPmh.postDelayed({
                ControlDevice.closeThisLight(7757)
            },200)
            mDataBind.tvPmh.postDelayed({
                ControlDevice.closeThisLight(7758)
            },400)
            mDataBind.tvPmh.postDelayed({
                ControlDevice.closeThisLight(7759)
            },600)

        }


        /**建设背景*/
        //上屏
        mDataBind.tvTxp1.setOnClickListener {
            mDataBind.tvTxp1.background = AppHelper.getDrawable(R.mipmap.icon_btn_public_1)
            mDataBind.tvTxp2.background = AppHelper.getDrawable(R.mipmap.icon_btn_public)
            mDataBind.tvTxp3.background = AppHelper.getDrawable(R.mipmap.icon_btn_public)

            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=ChangeScreen&object=0"
            OkHttpUtil.post(url);

            mDataBind.tvTxp1.postDelayed({
                initGetJSHYC()
            },300)
        }
        //中屏
        mDataBind.tvTxp2.setOnClickListener {
            mDataBind.tvTxp1.background = AppHelper.getDrawable(R.mipmap.icon_btn_public)
            mDataBind.tvTxp2.background = AppHelper.getDrawable(R.mipmap.icon_btn_public_1)
            mDataBind.tvTxp3.background = AppHelper.getDrawable(R.mipmap.icon_btn_public)

            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=ChangeScreen&object=1"
            OkHttpUtil.post(url);

            mDataBind.tvTxp2.postDelayed({
                initGetJSHYC()
            },300)
        }
        //下屏
        mDataBind.tvTxp3.setOnClickListener {
            mDataBind.tvTxp1.background = AppHelper.getDrawable(R.mipmap.icon_btn_public)
            mDataBind.tvTxp2.background = AppHelper.getDrawable(R.mipmap.icon_btn_public)
            mDataBind.tvTxp3.background = AppHelper.getDrawable(R.mipmap.icon_btn_public_1)

            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=ChangeScreen&object=2";
            OkHttpUtil.post(url);

            mDataBind.tvTxp3.postDelayed({
                initGetJSHYC()
            },300)

        }
        //建设背景添加欢迎词
        mDataBind.tvTjhyc99.setOnClickListener {
            AddU3DWelComeDialog.newInstance(
                false,
                120,
                "请输入文字",
                "",
                mDevice!!,
                object : AddU3DWelComeDialog.OnClickListener {
                    override fun onYes(i: Int, s: String, f: String) {
                        //删除按钮
                        val url =
                            "http://" + mDevice!!.ip + ":8030/?act=AddText&contain=" + s + "&size=" + i + "&font=" + f
                        OkHttpUtil.get(url, object : Callback {
                            override fun onFailure(call: Call, e: IOException) {}

                            @Throws(IOException::class)
                            override fun onResponse(call: Call, response: Response) {
                                if (response.isSuccessful) {
                                    mDataBind.tvTjhyc.postDelayed({
                                        initGetJSHYC()
                                    }, 500)
                                }
                            }
                        })
                    }
                }
            ).show(this@Main1Activity.supportFragmentManager, "AddU3DWelComeDialog1312143")
        }
        //建设背景轮播欢迎词
        mDataBind.tvXtlbxh99.setOnClickListener {
            U3dHttp.LoopWel(mDevice!!.ip)
        }
        //建设背景停止滚动
        mDataBind.tvTczg99.setOnClickListener {
            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=StopLoop&object="
            OkHttpUtil.post(url);
        }
        //建设背景鼠键
        mDataBind.tvShjj99.setOnClickListener {
            ARouter.to(SJActivity::class.java,mDevice!!.ip)
        }



        /**大事记*/
        //关闭弹窗
        mDataBind.tvDsjGb.setOnClickListener {
            val url = "http://" + mDevice!!.ip +":8030/?act=unity&states=ClosePanel&object="
            OkHttpUtil.post(url);
        }
        //上一个
        mDataBind.tvQsyy132.setOnClickListener {
            LocalHttp.getTMData(this,mDevice!!.ip,object :LocalHttp.GetTMListener{
                override fun getData(tMList: TMBean.TMList?) {
                    if (tMList?.index != 0){
                        setPlay(9)
                        mAdapter1321!!.setPosition(tMList!!.index - 1)
                    }
                }
            })
        }
        //下一个
        mDataBind.tvQxyy132.setOnClickListener {
            LocalHttp.getTMData(this,mDevice!!.ip,object :LocalHttp.GetTMListener{
                override fun getData(tMList: TMBean.TMList?) {
                    if (tMList?.index != mAdapter132!!.data!!.size-1){
                        setPlay(10)
                        mAdapter1321!!.setPosition(tMList!!.index + 1)
                    }
                }
            })
        }
        //鼠键
        mDataBind.tvShujiann8832.setOnClickListener {
            ARouter.to(SJActivity::class.java,mDevice!!.ip)
        }
        //播放
        mDataBind.zkPlay6632.setOnClickListener {
            setPlay(1)
            //U3dHttp.PlayMovie(mDevice!!.ip)
        }
        //暂停
        mDataBind.zkPause6632.setOnClickListener {
            setPlay(2)
            //U3dHttp.PauseMovie(mDevice!!.ip)
        }
        //重播
        mDataBind.zkReplay6632.setOnClickListener {
            setPlay(3)
            //U3dHttp.ReplayMovie(mDevice!!.ip)
        }
        //大事记声音滑动监听
        mDataBind.zkVolumeSeekbar6632.setOnSeekBarChangeListener(object :
            SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                LocalHttp.changeVoice(mDevice!!.ip, progress)
            }

            override fun onStartTrackingTouch(seekBar: SeekBar) {
            }

            override fun onStopTrackingTouch(seekBar: SeekBar) {
            }
        })
        //大事记视频滑动监听
        mDataBind.zkVideoSeekbar6632.setOnSeekBarChangeListener(object :
            SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                pMove = progress
            }

            override fun onStartTrackingTouch(seekBar: SeekBar) {
            }

            override fun onStopTrackingTouch(seekBar: SeekBar) {
                LocalHttp.changeMovie(mDevice!!.ip, pMove)
                //U3dHttp.changeMovie(mDevice!!.ip, pMove)
            }
        })


        /**创建基础*/
        //创建基础关闭弹窗
        mDataBind.tvGbbtc.setOnClickListener {
            //重置对应数据
            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=ClosePanel&object=$mSInt";
            OkHttpUtil.post(url);
        }
        //上一个
        mDataBind.tvQsyy1.setOnClickListener {
            LocalHttp.getTMData(this,mDevice!!.ip,object :LocalHttp.GetTMListener{
                override fun getData(tMList: TMBean.TMList?) {
                    if (tMList?.index != 0){
                        mAdapterCJJC1!!.setPosition(tMList!!.index - 1)
                        setPlay(9)
                    }
                }
            })
        }
        //下一个
        mDataBind.tvQxyy1.setOnClickListener {
            LocalHttp.getTMData(this,mDevice!!.ip,object :LocalHttp.GetTMListener{
                override fun getData(tMList: TMBean.TMList?) {
                    if (tMList?.index != mAdapterCJJC1!!.data!!.size-1){
                        mAdapterCJJC1!!.setPosition(tMList!!.index + 1)
                        setPlay(10)
                    }
                }
            })
        }
        //主题切换
        mDataBind.tvZtqh1.setOnClickListener {
            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=SelectTopic&object=";
            OkHttpUtil.post(url)
            mDataBind.tvZtqh1.postDelayed({
                otherList()
            },500)
        }
        //创建基础鼠键
        mDataBind.tvShujiann99.setOnClickListener {
            ARouter.to(SJActivity::class.java,mDevice!!.ip)
        }
        //播放
        mDataBind.zkPlay66.setOnClickListener {
            setPlay(1)
            //U3dHttp.PlayMovie(mDevice!!.ip)
        }
        //暂停
        mDataBind.zkPause66.setOnClickListener {
            setPlay(2)
            //U3dHttp.PauseMovie(mDevice!!.ip)
        }
        //重播
        mDataBind.zkReplay66.setOnClickListener {
            setPlay(3)
            //U3dHttp.ReplayMovie(mDevice!!.ip)
        }
        //创建基础声音滑动监听
        mDataBind.zkVolumeSeekbar66.setOnSeekBarChangeListener(object :
            SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                LocalHttp.changeVoice(mDevice!!.ip, progress)
            }

            override fun onStartTrackingTouch(seekBar: SeekBar) {
            }

            override fun onStopTrackingTouch(seekBar: SeekBar) {
            }
        })
        //创建基础视频滑动监听
        mDataBind.zkVideoSeekbar66.setOnSeekBarChangeListener(object :
            SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                pMove = progress
            }

            override fun onStartTrackingTouch(seekBar: SeekBar) {
            }

            override fun onStopTrackingTouch(seekBar: SeekBar) {
                LocalHttp.changeMovie(mDevice!!.ip, pMove)
                //U3dHttp.changeMovie(mDevice!!.ip, pMove)
            }
        })


        /**阶段成果*/
        //创建基础关闭弹窗
        mDataBind.tvGbbtc99.setOnClickListener {
            //重置对应数据
            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=ClosePanel&object=$mSInt";
            OkHttpUtil.post(url);
        }
        //上一个
        mDataBind.tvQsyy199.setOnClickListener {
            U3dHttp.getCGIndex(mDevice!!.ip,object :U3dHttp.GetCGIndexListener{
                override fun getData(index: Int) {
                    mDataBind.tvQsyy199.post {
                        mAdapter199?.setPosition(index)
                    }
                }
            })
            U3dHttp.PrevPage(mDevice!!.ip)
        }
        //下一个
        mDataBind.tvQxyy199.setOnClickListener {
            U3dHttp.getCGIndex(mDevice!!.ip,object :U3dHttp.GetCGIndexListener{
                override fun getData(index: Int) {
                    mDataBind.tvQsyy199.post {
                        mAdapter199?.setPosition(index)
                    }
                }
            })
            U3dHttp.NextPage(mDevice!!.ip)
        }
        //阶段成果鼠键
        mDataBind.tvShujiann88.setOnClickListener {
            ARouter.to(SJActivity::class.java,mDevice!!.ip)
        }
        //播放
        mDataBind.zkPlay77.setOnClickListener {
            //setPlay(1)
            U3dHttp.PlayMovie(mDevice!!.ip)
        }
        //暂停
        mDataBind.zkPause77.setOnClickListener {
            //setPlay(2)
            U3dHttp.PauseMovie(mDevice!!.ip)
        }
        //重播
        mDataBind.zkReplay77.setOnClickListener {
            //setPlay(3)
            U3dHttp.ReplayMovie(mDevice!!.ip)
        }
        //阶段成果声音滑动监听
        mDataBind.zkVolumeSeekbar77.setOnSeekBarChangeListener(object :
            SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                LocalHttp.changeVoice(mDevice!!.ip, progress)
            }

            override fun onStartTrackingTouch(seekBar: SeekBar) {
            }

            override fun onStopTrackingTouch(seekBar: SeekBar) {
            }
        })
        //阶段成果视频滑动监听
        mDataBind.zkVideoSeekbar77.setOnSeekBarChangeListener(object :
            SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                pMove = progress
            }

            override fun onStartTrackingTouch(seekBar: SeekBar) {
            }

            override fun onStopTrackingTouch(seekBar: SeekBar) {
                //LocalHttp.changeMovie(mDevice!!.ip, pMove)
                U3dHttp.changeMovie(mDevice!!.ip, pMove)
            }
        })


        /**合规沙盒*/
        //合规沙盘返回
        mDataBind.tvHgFh.setOnClickListener {
            //重置对应数据
            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=back&object=";
            OkHttpUtil.post(url);
        }
        //合规沙盘首页
        mDataBind.tvHgSy.setOnClickListener {
            //发送首页命令
            val url = "http://"+ mDevice!!.ip + ":8030/?act=unity&states=home&object=";
            OkHttpUtil.post(url)
        }
        //鼠键
        mDataBind.tvHgSj.setOnClickListener {
            ARouter.to(SJActivity::class.java,mDevice!!.ip)
        }

    }

    private fun showView() {
        mDataBind.clXt.gone()
        mDataBind.clTxp.gone()
        mDataBind.clDsj.gone()
        mDataBind.clCjjc.gone()
        mDataBind.clQt.gone()
        mDataBind.clHgsh.gone()

        //默认显示哪一个
        when (mTag) {
            14053 -> {
                //序厅",
                mDataBind.clXt.visible()
            }
            14054 -> {
                //建设背景"
                initGetJSHYC()
                mDataBind.clTxp.visible()
            }
            14055 -> {
                //大事记"
                mDataBind.clDsj.visible()
                dsjList()
            }
            14056 -> {
                //创建基础
                //3D
                mDataBind.clCjjc.visible()
                otherList()
            }
            14057 -> {
                //阶段成果
                mDataBind.clQt.visible()
                cgList()
            }
            14058 -> {
                //合规沙盒
                mDataBind.clHgsh.visible()
                hgList()
            }
        }
    }

    private fun setList() {
        //这个集合存储的是每一层级的样式以及信息，会根据该集合的长度去创建最大多少级
        val mList: ArrayList<GetListUtils.GetListData> = ArrayList<GetListUtils.GetListData>()
        mList.add(GetListUtils.GetListData(itemSize = 16f, leftMargin = 20))
        GetListUtils.find(mDataBind.clAll, this, mList)

        //设置一级目录
        val mSXList: ArrayList<GetListUtils.TestData> = ArrayList<GetListUtils.TestData>()
        mSXList.add(GetListUtils.TestData("序厅", 14053))
        mSXList.add(GetListUtils.TestData("建设背景", 14054))
        mSXList.add(GetListUtils.TestData("大事记", 14055))
        mSXList.add(GetListUtils.TestData("创建基础", 14056))
        mSXList.add(GetListUtils.TestData("阶段成果", 14057))
        mSXList.add(GetListUtils.TestData("合规沙盒", 14058))

        //设置默认哪个选中
        mSXList.forEach {
            if (it.Tag == mDevice!!.id) {
                it.select = true
            }
        }
        GetListUtils.setListData(1, mSXList, object : GetListUtils.OnListener {
            override fun onClick(l: GetListUtils.TestData) {
                mTag = l.Tag!!
                mDevice = ControlDevice.getThisDevice(mTag)
                //mDevice!!.ip = "192.168.10.23"
                //mDevice!!.ip = "192.168.0.107"
                //获取本地列表
                getLocalList()
                //显示对应视图
                showView()
            }
        })
    }

    private var movieR: Runnable = object : Runnable {
        override fun run() {
            getMove()
            handler?.postDelayed(this, 1000)
        }
    }


    //大事记列表  老的客户端
    private fun dsjList1() {
        val ms132 = LinearLayoutManager(this)
        mAdapter1321  = CJListAdapter(mDevice!!,3)
        mDataBind.rvOtherList132.layoutManager = ms132
        mDataBind.rvOtherList132.adapter = mAdapter1321

        LocalHttp.getPlayData(this, mDevice!!.ip, LocalHttp.GetPlayDataListener {
            if (it.isNotEmpty()) {
                mAdapter1321?.setList(it)
            }
        })
    }


    //大事记列表  新的程序
    private fun dsjList() {
        val ms = GridLayoutManager(this,2)
        ms.orientation = RecyclerView.HORIZONTAL
        //新建列表适配器
        val mAdapter = DSJListAdapter1()
        //给列表绑定布局管理
        mDataBind.rvOtherList132.layoutManager = ms
        //给列表设置适配器
        mDataBind.rvOtherList132.adapter = mAdapter
        //加在setAdapter后面
        var mList: ArrayList<JsonRootBean> = arrayListOf()
        mDataBind.sbDsj.setOnSeekBarChangeListener(object :
            SeekBar.OnSeekBarChangeListener {
            override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
                mDataBind.rvOtherList132.postDelayed({
                    val mI = mList.size/2 - progress*2
                    if (mI > -1){
                        (mDataBind.rvOtherList132.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(mI, 0)
                    }
                },100)
                OkHttpUtil.post("http://" + mDevice!!.ip +":8030/?act=unity&states=ShowPanel&object=${progress}")
            }

            override fun onStartTrackingTouch(seekBar: SeekBar) {
            }

            override fun onStopTrackingTouch(seekBar: SeekBar) {
            }
        })


        /*val responseString = "[{\"Interactable\":false,\"Title\":\"22\\\\12\\\\19\",\"ID\":\"2023\"},{\"Interactable\":false,\"Title\":\"22\\\\12\\\\30\",\"ID\":\"2024\"},{\"Interactable\":false,\"Title\":\"23\\\\2\\\\9\",\"ID\":\"2025\"},{\"Interactable\":true,\"Title\":\"23\\\\2\\\\24\",\"ID\":\"2026\"},{\"Interactable\":false,\"Title\":\"23\\\\3\\\\9\",\"ID\":\"2027\"},{\"Interactable\":true,\"Title\":\"23\\\\3\\\\23\",\"ID\":\"2028\"},{\"Interactable\":false,\"Title\":\"23\\\\4\\\\25\",\"ID\":\"2029\"},{\"Interactable\":true,\"Title\":\"23\\\\8\\\\23\",\"ID\":\"2030\"},{\"Interactable\":false,\"Title\":\"23\\\\9\\\\9\",\"ID\":\"2031\"},{\"Interactable\":false,\"Title\":\"23\\\\9\\\\21\",\"ID\":\"2032\"},{\"Interactable\":false,\"Title\":\"23\\\\10\\\\13\",\"ID\":\"2033\"},{\"Interactable\":true,\"Title\":\"23\\\\11\\\\9\",\"ID\":\"2034\"},{\"Interactable\":true,\"Title\":\"23\\\\11\\\\23\",\"ID\":\"2035\"},{\"Interactable\":false,\"Title\":\"23\\\\12\\\\14\",\"ID\":\"2036\"},{\"Interactable\":false,\"Title\":\"23\\\\12\\\\28\",\"ID\":\"2037\"},{\"Interactable\":false,\"Title\":\"24\\\\1\\\\1、9、12\",\"ID\":\"2038\"},{\"Interactable\":false,\"Title\":\"24\\\\1\\\\19\",\"ID\":\"2039\"},{\"Interactable\":false,\"Title\":\"24\\\\2\\\\18\",\"ID\":\"2040\"},{\"Interactable\":true,\"Title\":\"24\\\\4\\\\8\",\"ID\":\"2041\"},{\"Interactable\":true,\"Title\":\"24\\\\4\\\\23\",\"ID\":\"2042\"},{\"Interactable\":true,\"Title\":\"24\\\\4\\\\25\",\"ID\":\"2043\"}]"
        mList = JSONArray.parseArray(responseString, JsonRootBean::class.java) as ArrayList<JsonRootBean>
        if (mList.size % 2 == 1){
            val mJ = JsonRootBean()
            mJ.interactable = false
            mJ.title = ""
            mJ.id = ""
            mList.add(mJ)
        }
        mList.reverse()
        mDataBind.rvOtherList132.post {
            mAdapter.setList(mList, this@Main1Activity)
            mDataBind.sbDsj.max = mList.size/2
            mDataBind.rvOtherList132.postDelayed(Runnable {
                mDataBind.rvOtherList132.scrollToPosition(mList.size - 1)
            },200)
        }*/


        val url = "http://" + mDevice!!.ip +":8030/?act=unity&states=BtnInfo"
        val client = OkHttpClient()
        val request: Request = Request.Builder().url(url).build()
        val call = client.newCall(request)
        call.enqueue(object : Callback {
            override fun onFailure(call: Call, e: IOException) {}

            @Throws(IOException::class)
            override fun onResponse(call: Call, response: Response) {
                if (response.isSuccessful) {
                    val responseString = response.body!!.string()
                    mList = JSONArray.parseArray(responseString, JsonRootBean::class.java) as ArrayList<JsonRootBean>
                    if (mList.size % 2 == 1){
                        val mJ = JsonRootBean()
                        mJ.interactable = false
                        mJ.title = ""
                        mJ.id = ""
                        mList.add(mJ)
                    }
                    mList.reverse()

                    //集合肯定是偶数，颠倒数据
                    var i = 0
                    while (i < mList.size) {
                        i += 2
                        Log.e("TAG", "dsjList:21312321 ---初:${i-2},末:${i-1}")
                        Collections.swap(mList,i-2,i-1)
                    }

                    mDataBind.rvOtherList132.post {
                        mAdapter.setList(mList, this@Main1Activity,mDevice)
                        mDataBind.sbDsj.max = mList.size/2
                         mDataBind.rvOtherList132.postDelayed(Runnable {
                              mDataBind.rvOtherList132.scrollToPosition(mList.size - 1)
                         },200)
                    }
                }
            }
        })

    }

    //创建基础
    private fun otherList() {
        val ms1 = LinearLayoutManager(this)
        val ms2 = LinearLayoutManager(this)
        //ms.orientation = LinearLayoutManager.HORIZONTAL // 设置 recyclerview 布局方式为横向布局
        mAdapterCJJC1 = CJListAdapter111(mDevice!!,3)
        //val mAdapter2 = CJListAdapter(mDevice!!,1)
        mDataBind.rvOtherList1.layoutManager = ms1
        mDataBind.rvOtherList1.adapter = mAdapterCJJC1

        //mDataBind.rvOtherList2.layoutManager = ms2
        //mDataBind.rvOtherList2.adapter = mAdapter2

        LocalHttp.getPlayData(this, mDevice!!.ip, LocalHttp.GetPlayDataListener {
            if (it.isNotEmpty()) {
                mAdapterCJJC1!!.setList(it)
            }
        })

        //页码内容
        /*U3dHttp.getU3dCJFYData(this,mDevice!!.ip,object : U3dHttp.GetU3dCJFYDataListener {
            override fun getData(mBean: MutableList<String>?) {
                val l: ArrayList<Flash> = arrayListOf()
                if (mBean != null){
                    mBean.forEach {
                        l.add(Flash(it))
                    }
                }
                mDataBind.rvList.post {
                    mAdapter1.setList(l)
                }
            }

        } )*/

        //树的内容
        /*U3dHttp.getU3dCJData(this,mDevice!!.ip,object : U3dHttp.GetU3dCJDataListener {
            override fun getData(mBean: MutableList<String>?) {
                val l: ArrayList<Flash> = arrayListOf()
                if (mBean != null){
                    mBean.forEach {
                        l.add(Flash(it))
                    }
                }
                mDataBind.rvList.post {
                    mAdapter2.setList(l)
                }
            }

        } )*/

        /*mAdapter.setOnItemClickListener { adapter, view, position ->
            //更改选中状态
            val mT = adapter.data as MutableList<AreaList>
            mT.forEach {
                it.select = false
            }
            mT[position].select = true
            adapter.notifyDataSetChanged()
            mSInt = position
            //重置对应数据
            val url = "http://" + mDevice!!.ip +":8030/?act=unity&states=SelectVideo&object=$position"
            OkHttpUtil.post(url);
        }*/
    }


    //阶段成果
    private fun cgList() {
        val ms1 = LinearLayoutManager(this)
        val ms2 = LinearLayoutManager(this)
        //ms.orientation = LinearLayoutManager.HORIZONTAL // 设置 recyclerview 布局方式为横向布局
        mAdapter199 = CJListAdapter(mDevice!!,0)
        mAdapter199?.setOnMyClickListener(object :CJListAdapter.OnClickListener{
            override fun on(item: Flash) {
                if (item.title.contains("科技树")){
                    mDataBind.rvOtherList299.visible()
                }else{
                    mDataBind.rvOtherList299.gone()
                }
            }

        })

        val mAdapter2 = CJListAdapter(mDevice!!,1)
        mDataBind.rvOtherList199.layoutManager = ms1
        mDataBind.rvOtherList199.adapter = mAdapter199

        mDataBind.rvOtherList299.gone()
        mDataBind.rvOtherList299.layoutManager = ms2
        mDataBind.rvOtherList299.adapter = mAdapter2

        //页码内容
        U3dHttp.getU3dCJFYData(this,mDevice!!.ip,object : U3dHttp.GetU3dCJFYDataListener {
            override fun getData(mBean: MutableList<String>?) {
                val l: ArrayList<Flash> = arrayListOf()
                if (mBean != null){
                    mBean.forEach {
                        l.add(Flash(it))
                    }
                }
                mDataBind.rvList.post {
                    mAdapter199?.setList(l)
                }
            }

        } )

        //树的内容
        U3dHttp.getU3dCJData(this,mDevice!!.ip,object : U3dHttp.GetU3dCJDataListener {
            override fun getData(mBean: MutableList<String>?) {
                val l: ArrayList<Flash> = arrayListOf()
                if (mBean != null){
                    mBean.forEach {
                        l.add(Flash(it))
                    }
                }
                mDataBind.rvList.post {
                    mAdapter2.setList(l)
                }
            }

        } )
    }


    //设置合规沙盘列表适配器
    var mAdapterHG1: GetListUtils.QnZtListAdapter ?= null;
    var mAdapterHG2: GetListUtils.QnZtListAdapter ?= null;
    private fun onHGRV(){
        mDataBind.rvHgList1.layoutManager = LinearLayoutManager(this)
        mDataBind.rvHgList1.itemAnimator = DefaultItemAnimator()

        mAdapterHG1 = GetListUtils.QnZtListAdapter(R.layout.item_get_list, GetListUtils.GetListData())
        mDataBind.rvHgList1.adapter = mAdapterHG1

        mDataBind.rvHgList2.layoutManager = LinearLayoutManager(this)
        mDataBind.rvHgList2.itemAnimator = DefaultItemAnimator()

        mAdapterHG2 = GetListUtils.QnZtListAdapter(R.layout.item_get_list, GetListUtils.GetListData())
        mDataBind.rvHgList2.adapter = mAdapterHG2
    }

    //合规沙盘
    private fun hgList() {
        U3dHttp.getU3dData(this,mDevice!!.ip,object : U3dHttp.GetU3dDataListener{
            override fun getData(mBean: U3dListBean?) {
                if (mBean != null){
                    setDSJList(0,mBean,true,object :OnDSJListener{
                        override fun getData(list: ArrayList<GetListUtils.TestData>) {
                            if (mAdapterHG1 != null){
                                mAdapterHG1!!.setList(list)
                                mAdapterHG1!!.setOnItemClickListener { adapter, view, position ->
                                    val mData: ArrayList<GetListUtils.TestData> = adapter.data as ArrayList<GetListUtils.TestData>
                                    //刷新选中状态
                                    mData.forEach {
                                        it.select = false
                                    }
                                    mData[position].select = true
                                    adapter.notifyDataSetChanged()
                                    U3dHttp.PostChannel(mDevice!!.ip,mData[position].Tag!!)

                                    setDSJList(mData[position].Tag!!,mBean,false,object : OnDSJListener{
                                        override fun getData(list: ArrayList<GetListUtils.TestData>) {
                                                if (mAdapterHG2 != null) {
                                                    mAdapterHG2!!.setList(list)
                                                    mAdapterHG2!!.setOnItemClickListener { adapter, view, position ->
                                                        val mData2: ArrayList<GetListUtils.TestData> =
                                                            adapter.data as ArrayList<GetListUtils.TestData>
                                                        //刷新选中状态
                                                        mData2.forEach {
                                                            it.select = false
                                                        }
                                                        mData2[position].select = true
                                                        adapter.notifyDataSetChanged()

                                                        U3dHttp.PostContent(
                                                            mDevice!!.ip,
                                                            mData2[position].Tag!!
                                                        )
                                                    }
                                                }
                                        }
                                    })
                                }
                            }
                        }
                    })
                }

            }
        })
    }


    //获取本地资源列表
    private fun getLocalList() {
        if (mTag == 14054) {
            //条形屏的
            //获取程序的欢迎词数据
            initGet3DHYC()
        }
        if (mTag == 14053 && mXTAdapter != null){
            //获取视频播放列表
            U3dHttp.getU3dCJData(this,mDevice!!.ip,object : U3dHttp.GetU3dCJDataListener {
                override fun getData(mBean: MutableList<String>?) {
                    val l: ArrayList<Flash> = arrayListOf()
                    if (mBean != null){
                        mBean.forEach {
                            l.add(Flash(it))
                        }
                    }
                    mDataBind.rvList.post {
                        mXTAdapter!!.setList(l)
                    }
                }

            } )
        }
    }

    private fun initXTRV() {
        //序厅的视频播放
        mDataBind.rvLocalList.layoutManager = LinearLayoutManager(BaseApplication.getContext())
        mDataBind.rvLocalList.itemAnimator = DefaultItemAnimator()
        mXTAdapter = CJListAdapter(mDevice!!,2)
        mDataBind.rvLocalList.adapter = mXTAdapter
    }

    private fun initRV() {
        mDataBind.rvList.layoutManager = LinearLayoutManager(this)
        mDataBind.rvList.itemAnimator = DefaultItemAnimator()
    }


    private fun initJSRV() {
        mDataBind.rvList99.layoutManager = LinearLayoutManager(this)
        mDataBind.rvList99.itemAnimator = DefaultItemAnimator()
    }


    private fun initGet3DHYC() {
        if (hycZhAdapter != null) {
            hycZhAdapter!!.closeMenu()
        }
        U3dHttp.getU3dWel(this, mDevice!!.ip) { mBean ->
            if (mBean != null && mBean.list != null) {
                setMList(mBean.list)
            }
        }
    }

    private fun setMList(mList: List<U3DHyc>) {
        if (hycZhAdapter != null) {
            hycZhAdapter!!.upData(mList)
        } else {
            hycZhAdapter = U3dHycAdapter(
                this,
                object : U3dHycAdapter.ZuohuaSlidingViewClickListener {
                    override fun onItemClick(view: View?, position: Int) {
                        //点击欢迎词
                        U3dHttp.SelectWel(mDevice!!.ip, position)
                    }

                    override fun onDelBtnCilck(view: View?, position: Int, bfList: List<U3DHyc?>?) {
                        //删除按钮
                        val url =
                            "http://" + mDevice!!.ip + ":8030/?act=unity&states=DeleteText&object=" + position
                        OkHttpUtil.get(url, object : Callback {
                            override fun onFailure(call: Call, e: IOException) {}

                            @Throws(IOException::class)
                            override fun onResponse(call: Call, response: Response) {
                                if (response.isSuccessful) {
                                    mDataBind.rvList.postDelayed({
                                        initGet3DHYC()
                                    }, 500)
                                }
                            }
                        })
                    }

                    override fun onEditBtnClick(view: View?, position: Int) {
                        val u3DHyc = hycZhAdapter!!.data[position];
                        //编辑按钮
                        AddU3DWelComeDialog.newInstance(
                            true,
                            u3DHyc.Size,
                            u3DHyc.Content,
                            u3DHyc.Font,
                            mDevice!!,
                            object : AddU3DWelComeDialog.OnClickListener {
                                override fun onYes(i: Int, s: String, f: String) {
                                    var upNum = 0
                                    var urlNum = 0
                                    if (u3DHyc.Size != i) {
                                        upNum += 1
                                        U3dHttp.ChangeWelSizeContent(mDevice!!.ip, position, i) {
                                            urlNum += 1;
                                            if (urlNum == upNum) {
                                                mDataBind.rvList.post {
                                                    u3DHyc.Content = s
                                                    u3DHyc.Size = i
                                                    u3DHyc.Font = f
                                                    hycZhAdapter!!.upData(mList)
                                                }
                                            }
                                        }
                                    }
                                    if (u3DHyc.Content != s) {
                                        upNum += 1
                                        U3dHttp.ChangeWelContent(mDevice!!.ip, position, s) {
                                            urlNum += 1;
                                            if (urlNum == upNum) {
                                                mDataBind.rvList.post {
                                                    u3DHyc.Content = s
                                                    u3DHyc.Size = i
                                                    u3DHyc.Font = f
                                                    hycZhAdapter!!.upData(mList)
                                                }
                                            }
                                        }
                                    }
                                    if (u3DHyc.Font != f) {
                                        upNum += 1
                                        U3dHttp.ChangeWelFontContent(mDevice!!.ip, position, f) {
                                            urlNum += 1;
                                            if (urlNum == upNum) {
                                                mDataBind.rvList.post {
                                                    u3DHyc.Content = s
                                                    u3DHyc.Size = i
                                                    u3DHyc.Font = f
                                                    hycZhAdapter!!.upData(mList)
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        ).show(this@Main1Activity.supportFragmentManager, "AddU3DWelComeDialog1313")
                    }
                }, mList
            )
            mDataBind.rvList.adapter = hycZhAdapter

        }
    }

    //建设背景欢迎词
    private fun initGetJSHYC() {
        if (jsAdapter != null) {
            jsAdapter!!.closeMenu()
        }
        U3dHttp.getU3dWel(this, mDevice!!.ip) { mBean ->
            if (mBean != null && mBean.list != null) {
                setJSList(mBean.list)
            }
        }
    }

    private fun setJSList(mList: List<U3DHyc>) {
        if (jsAdapter != null) {
            jsAdapter!!.upData(mList)
        } else {
            jsAdapter = U3dHycAdapter(
                this,
                object : U3dHycAdapter.ZuohuaSlidingViewClickListener {
                    override fun onItemClick(view: View?, position: Int) {
                        //点击欢迎词
                        U3dHttp.SelectWel(mDevice!!.ip, position)
                    }

                    override fun onDelBtnCilck(view: View?, position: Int, bfList: List<U3DHyc?>?) {
                        //删除按钮
                        val url =
                            "http://" + mDevice!!.ip + ":8030/?act=unity&states=DeleteText&object=" + position
                        OkHttpUtil.get(url, object : Callback {
                            override fun onFailure(call: Call, e: IOException) {}

                            @Throws(IOException::class)
                            override fun onResponse(call: Call, response: Response) {
                                if (response.isSuccessful) {
                                    mDataBind.rvList99.postDelayed({
                                        initGetJSHYC()
                                    }, 500)
                                }
                            }
                        })
                    }

                    override fun onEditBtnClick(view: View?, position: Int) {
                        val u3DHyc = jsAdapter!!.data[position];
                        //编辑按钮
                        AddU3DWelComeDialog.newInstance(
                            false,
                            u3DHyc.Size,
                            u3DHyc.Content,
                            u3DHyc.Font,
                            mDevice!!,
                            object : AddU3DWelComeDialog.OnClickListener {
                                override fun onYes(i: Int, s: String, f: String) {
                                    var upNum = 0
                                    var urlNum = 0
                                    if (u3DHyc.Size != i) {
                                        upNum += 1
                                        U3dHttp.ChangeWelSizeContent(mDevice!!.ip, position, i) {
                                            urlNum += 1;
                                            if (urlNum == upNum) {
                                                mDataBind.rvList99.post {
                                                    u3DHyc.Content = s
                                                    u3DHyc.Size = i
                                                    u3DHyc.Font = f
                                                    jsAdapter!!.upData(mList)
                                                }
                                            }
                                        }
                                    }
                                    if (u3DHyc.Content != s) {
                                        upNum += 1
                                        U3dHttp.ChangeWelContent(mDevice!!.ip, position, s) {
                                            urlNum += 1;
                                            if (urlNum == upNum) {
                                                mDataBind.rvList99.post {
                                                    u3DHyc.Content = s
                                                    u3DHyc.Size = i
                                                    u3DHyc.Font = f
                                                    jsAdapter!!.upData(mList)
                                                }
                                            }
                                        }
                                    }
                                    if (u3DHyc.Font != f) {
                                        upNum += 1
                                        U3dHttp.ChangeWelFontContent(mDevice!!.ip, position, f) {
                                            urlNum += 1;
                                            if (urlNum == upNum) {
                                                mDataBind.rvList99.post {
                                                    u3DHyc.Content = s
                                                    u3DHyc.Size = i
                                                    u3DHyc.Font = f
                                                    jsAdapter!!.upData(mList)
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        ).show(this@Main1Activity.supportFragmentManager, "AddU3DWelComeDialog1313")
                    }
                }, mList
            )
            mDataBind.rvList99.adapter = jsAdapter

        }
    }


    /*
     * @param ip
     * @param port
     * @param type
     * 1:播放
     * 2:暂停
     * 3:重播
     * 5:上一个
     * 6:下一个
     * 7：上一页
     * 8：下一页
     * 9：列表上一个
     * 10：列表下一个
     * 11：隐藏客户端
     * 12：显示客户端
     */
    private fun setPlay(i: Int) {
        LocalHttp.moviePlay(mDevice!!.ip, i)
    }

    private fun getVoice() {
        LocalHttp.getVoiceSize(mDevice!!.ip, LocalHttp.GetVoiceSizeListener {
            mDataBind.zkVolumeSeekbar.post {
                mDataBind.zkVolumeSeekbar.progress = it
                mDataBind.zkVolumeSeekbar66.progress = it
                mDataBind.zkVolumeSeekbar77.progress = it
                mDataBind.zkVolumeSeekbar6632.progress = it
            }
        })
    }

    private fun getMove() {
        if (mTag == 14053) {
            //序厅
            U3dHttp.getMovieSize(mDevice!!.ip, object : U3dHttp.GetMovieSizeListener {
                override fun getData(
                    maxTxt: String?,
                    minTxt: String?,
                    maxSeekBar: Int,
                    seekProgress: Int
                ) {
                    mDataBind.zkVideoSeekbar.post {
                        //序厅
                        mDataBind.zkMaxTime.text = maxTxt
                        mDataBind.zkMinTime.text = minTxt
                        mDataBind.zkVideoSeekbar.max = maxSeekBar
                        mDataBind.zkVideoSeekbar.progress = seekProgress
                    }
                }
            })
        }
        if (mTag == 14056) {
            //创建基础
            LocalHttp.getMovieSize(mDevice!!.ip,LocalHttp.GetMovieSizeListener { maxTxt, minTxt, maxSeekBar, seekProgress ->
                mDataBind.zkVideoSeekbar66.post {
                    mDataBind.zkMaxTime66.text = maxTxt
                    mDataBind.zkMinTime66.text = minTxt
                    mDataBind.zkVideoSeekbar66.max = maxSeekBar
                    mDataBind.zkVideoSeekbar66.progress = seekProgress
                }
            })
        }
        if (mTag == 14055){
            //大事记
            LocalHttp.getMovieSize(mDevice!!.ip,LocalHttp.GetMovieSizeListener { maxTxt, minTxt, maxSeekBar, seekProgress ->
                mDataBind.zkVideoSeekbar6632.post {
                    mDataBind.zkMaxTime6632.text = maxTxt
                    mDataBind.zkMinTime6632.text = minTxt
                    mDataBind.zkVideoSeekbar6632.max = maxSeekBar
                    mDataBind.zkVideoSeekbar6632.progress = seekProgress
                }
            })
        }
        if (mTag == 14057) {
            //阶段成果
            U3dHttp.getMovieSize(mDevice!!.ip, object : U3dHttp.GetMovieSizeListener {
                override fun getData(
                    maxTxt: String?,
                    minTxt: String?,
                    maxSeekBar: Int,
                    seekProgress: Int
                ) {
                    mDataBind.zkVideoSeekbar.post {
                        //序厅
                        mDataBind.zkMaxTime77.text = maxTxt
                        mDataBind.zkMinTime77.text = minTxt
                        mDataBind.zkVideoSeekbar77.max = maxSeekBar
                        mDataBind.zkVideoSeekbar77.progress = seekProgress
                    }
                }
            })
        }
    }


    //获取大事记程序数据
    //获取数据通用回调，因为请求异步，加回调判断
    interface OnDSJListener {
        fun getData(list: ArrayList<GetListUtils.TestData>) //有参方法
    }
    private fun setDSJList(tag: Int, response: U3dListBean, isGetParent: Boolean, mListener: OnDSJListener) {
        var mPTag = tag
        val bhList: List<U3dListBean.BhList> = response.list
        val subColumns: List<U3dListBean.SubColumns> = response.subColumns
        if (isGetParent) {
            //筛选出父类
            for (b in subColumns) {
                if (0 == b.parentTag && canGet(b.name)) {
                    mPTag = b.tag
                }
            }
        }

        //筛选出对应的二级数据
        val mSXList: ArrayList<GetListUtils.TestData> = ArrayList<GetListUtils.TestData>()
        for (b in subColumns) {
            if (mPTag == b.parentTag && canGet(b.name)) {
                mSXList.add(GetListUtils.TestData(b.name, b.tag, b.parentTag))
            }
        }

        if (mSXList.isEmpty()) { //无数据，从list里面筛选
            for (h in bhList) {
                if (h.tag == mPTag && canGet(h.title)) {
                    mSXList.add( GetListUtils.TestData(h.title, h.id, h.tag))
                }
            }
        }

        mListener.getData(mSXList)
        //如果此时总数据还为0,则将list全部添加进去
        /*if (mSXList.size() == 0) {
            if (subColumns.size() == 0) {
                for (BhListBean.BhList h : bhList) {
                    mSXList.add(setData(h.getTitle(), h.getTag(), h.getID()));
                }
            }
        }*/
    }

    //动态筛选不需要的字符串
    private fun canGet(s: String): Boolean {
        return s !== "null" && !s.contains(".png") && !s.contains(".jpg")
    }

    override fun onDestroy() {
        super.onDestroy()
        if (handler != null) {
            handler?.removeCallbacks(movieR)
            handler = null
        }
    }

}